package com.hzvictory.hotel_system.service.Impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hzvictory.hotel_system.mapper.CollectionMapper;
import com.hzvictory.hotel_system.pojo.entity.Collection;
import com.hzvictory.hotel_system.service.ICollectionService;

/**
 * 收藏表Service业务层处理
 *
 * @author hzvictory
 * @date 2025-07-24
 */
@Service
public class CollectionServiceImpl implements ICollectionService
{
    @Autowired
    private CollectionMapper collectionMapper;

    /**
     * 查询收藏表
     *
     * @param id 收藏表主键
     * @return 收藏表
     */
    @Override
    public Collection selectCollectionById(Long id)
    {
        return collectionMapper.selectCollectionById(id);
    }

    /**
     * 查询收藏表列表
     *
     * @param collection 收藏表
     * @return 收藏表
     */
    @Override
    public List<Collection> selectCollectionList(Collection collection)
    {
        return collectionMapper.selectCollectionList(collection);
    }
    @Override
    public List<Collection> selectCollectionListByUserId(Long userId)
    {
        return collectionMapper.selectCollectionListByUserId(userId);
    }

    /**
     * 新增收藏表
     *
     * @param collection 收藏表
     * @return 结果
     */
    @Override
    public int insertCollection(Collection collection)
    {
        return collectionMapper.insertCollection(collection);
    }

    /**
     * 修改收藏表
     *
     * @param collection 收藏表
     * @return 结果
     */
    @Override
    public int updateCollection(Collection collection)
    {
        return collectionMapper.updateCollection(collection);
    }

    /**
     * 批量删除收藏表
     *
     * @param ids 需要删除的收藏表主键
     * @return 结果
     */
    @Override
    public int deleteCollectionByIds(Long[] ids)
    {
        return collectionMapper.deleteCollectionByIds(ids);
    }

    /**
     * 删除收藏表信息
     *
     * @param id 收藏表主键
     * @return 结果
     */
    @Override
    public int deleteCollectionById(Long id)
    {
        return collectionMapper.deleteCollectionById(id);
    }

    @Override
    public int deleteCollectionByInfo(Collection collection){
        Long delete_id=collectionMapper.selectIdByInfo(collection);
        return collectionMapper.deleteCollectionById(delete_id);
    }
}
